<%@ page language="java"
    pageEncoding="UTF-8"%>

<html>
	<head></head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>Rice mall注册</title>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" />
		<script src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js" type="text/javascript"></script>
		<script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script>
<!-- 引入自定义css文件 style.css -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css"/>

<style>
  body{
   margin-top:20px;
   margin:0 auto;
 }
 .carousel-inner .item img{
	 width:100%;
	 height:300px;
 }
 .container .row div{ 
	 /* position:relative;
	 float:left; */
 }
 
font {
    color: #3164af;
    font-size: 18px;
    font-weight: normal;
    padding: 0 10px;
}
 </style>


				<script>
						//页面载入事件
						$(function(){
							//alert("页面载入了");

							//点击图片--刷新图片
							//Jq方式获取标签对象,同时添加点击事件
							$("#img1").click(function(){
								//alert("点击事件触发");
								//改变它的src属性,Jquery方式给标签对象设置属性
								$(this).attr(
										 "src",
										"${pageContext.request.contextPath}/checkCode?time="+new Date().getTime()) ;
							}) ;



							//用户名输入之后,鼠标移出之后触发失去焦点事件
							$("#username").blur(function(){
								//异步校验用户名(昵称)是否可用
								//获取用户名的内容
								var username = $("#username").val() ;
								alert(username) ;
								//获取id="tip"标签对象
								var div = $("#tip");

								//发送ajax
								$.ajax({
									type:"get",
									url :"${pageContext.request.contextPath}/user?methodName=checkUser&username="+username+"",
									success:function(data){
										//服务器响应成功的回调函数
										//获取数据
										if(data.code==0){
											//可用
											//给$span设置标签文本
											div.html(data.msg) ;
											//设置样式
											div.css("color","green") ;
										}

										if(data.code==1){
											//不可用
											//给$span设置标签文本
											div.html(data.msg) ;
											//设置样式
											div.css("color","red") ;
											$("#username").css("border","1px solid red") ;
										}

									},
									dataType:"json"

								}) ;


								//如果写js表单校验,每一个表单元素---都满足正则条件,然后表单提交
								//表单提交---jquery的ajax提交表单
								/*$("#registerForm").submit(function(){

									$.ajax({
											url:"${pageContext.request.contextPath}/registerUser" ,//前台用户注册的服务地址
                                            type:"get",
										    data:$("#registerForm").serialize(),   //获取$("#registerForm")的表单,进行序列化操作
													//"key1=vaue1&key2=value2"
										    success:function(data){
												/!*if(data.code ==0){
													alert(data.msg) ;
												}*!/
												//服务器响应成功的回调函数
												//获取到的自定义数据里json串key-->data如果是true,
												//window.location.href = "" ;//跳转消息提示页,注册成功,请登录

											},
											dataType:"json"*/

									}) ;

								//}) ;

							//}) ;









						}) ;

				</script>
</head>
<body>



<%@include file="header.jsp"%>





<div class="container" style="width:100%;background:url('${pageContext.request.contextPath}/image/regist_bg.jpg');">
<div class="row"> 

	<div class="col-md-2"></div>
	
	


	<div class="col-md-8" style="background:#fff;padding:40px 80px;margin:30px;border:7px solid #ccc;">
		<font>注册</font>REGISTER
		<span style="color: red;margin-left: 100px;">${msg}</span>
		<form  action="${pageContext.request.contextPath}/user?methodName=registerUser" method="post" id="registerForm" class="form-horizontal" style="margin-top:5px;">
			 <div class="form-group">
			    <label for="username" class="col-sm-2 control-label">用户名</label>
			    <div class="col-sm-6">
			      <input type="text" class="form-control" id="username" name="username" placeholder="请输入用户名">
			    </div>

			  </div>
			<div style="margin-left: 150px;" id="tip"></div>
			   <div class="form-group">
			    <label for="inputPassword3" class="col-sm-2 control-label">密码</label>
			    <div class="col-sm-6">
			      <input type="password" class="form-control" name="password" id="inputPassword3" placeholder="请输入密码">
			    </div>
			  </div>
			   <div class="form-group">
			    <label for="confirmpwd" class="col-sm-2 control-label">确认密码</label>
			    <div class="col-sm-6">
			      <input type="password" class="form-control" id="confirmpwd" placeholder="请输入确认密码">
			    </div>
			  </div>
			  <div class="form-group">
			    <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
			    <div class="col-sm-6">
			      <input type="email" class="form-control" name="email" id="inputEmail3" placeholder="Email">
			    </div>
			  </div>
			 <div class="form-group">
			    <label for="usercaption" class="col-sm-2 control-label">姓名</label>
			    <div class="col-sm-6">
			      <input type="text" class="form-control" name="name" id="usercaption" placeholder="请输入姓名">
			    </div>
			  </div>
			  <div class="form-group opt">  
			  <label for="inlineRadio1" class="col-sm-2 control-label">性别</label>  
			  <div class="col-sm-6">
			    <label class="radio-inline">
			  <input type="radio" name="sex" id="inlineRadio1" value="男"> 男
			</label>
			<label class="radio-inline">
			  <input type="radio" name="sex" id="inlineRadio2" value="女"> 女
			</label>
			</div>
			  </div>		
			  <div class="form-group">
			    <label for="birthday" class="col-sm-2 control-label">出生日期</label>
			    <div class="col-sm-6">
			      <input type="date" id="birthday" name="birthday" class="form-control"  >
			    </div>
			  </div>
			  
			  <div class="form-group">
			    <label for="code" class="col-sm-2 control-label">验证码</label>
			    <div class="col-sm-3">
			      <input type="text" id="code" name="code" class="form-control"  >
			      
			    </div>
			    <div class="col-sm-2">
			    <img src="${pageContext.request.contextPath}/checkCode" id="img1"/>
			    </div>
			    
			  </div>
			 
			  <div class="form-group">
			    <div class="col-sm-offset-2 col-sm-10">
			      <input type="submit"  width="100" value="立即注册" border="0"
				    style="background: url('${pageContext.request.contextPath}/image/register.gif') no-repeat scroll 0 0 rgba(0, 0, 0, 0);
				    height:35px;width:100px;color:#000;background-color:#F7BE81">
			    </div>
			  </div>
			</form>
	</div>
	
	<div class="col-md-2"></div>
  
</div>
</div>



			<!--
                        描述：页脚部分
                    -->
			<div class="container-fluid">

				<div style="float: left;margin-left: 30px;margin-top: 25px">
					<img src="${pageContext.request.contextPath}/image/logo-mi2.png" width="80px" height="80px">
				</div>
				<div style="text-align: center;margin-top: 5px;float: left;margin-left: 30px;margin-top: 50px;text-align: center" >
					<ul class="list-inline">
						<li><a href="info.html">小米商城</a></li>|
						<li><a>MIUI</a></li>|
						<li><a>米家</a></li>|
						<li><a>多看</a></li>|
						<li><a>游戏</a></li>|
						<li><a>政企服务</a></li>|
						<li><a>小米天猫店</a></li>|
						<li><a>小米集团隐私政策</a></li>|
						<li><a>小米公司儿童信息保护规则</a></li>|
						<li><a>米家隐私</a></li>|
						<li><a>问题反馈</a></li>|
						<li><a>招贤纳士</a></li>|
						<li><a>投诉建议</a></li>
					</ul>
				</div>
				<div style="clear: both"></div>
				<div  style="text-align: center;margin-top: 5px;margin-bottom:20px;">

					Copyright &copy;2020-2030  Rice mall
				</div>
			</div>

</body></html>




